#!/usr/bin/env python3
# Created by han on 2016/7/4
import sys,os, hashlib

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

# obj = hashlib.md5()
# obj1 = hashlib.md5()
# with open("md5_test","rb") as test, open("md5_test1","wb") as test1:
#
#
#     print(test.tell())
#
# with open("md5_test1","rb") as test1:
#     test1.seek(3)
#     for i in test1:
#         print(i)
# #
# # obj1.update(a1)
#
# ret = obj.hexdigest()
# print(ret)

# a = public.GetFileMd5("D:\影音\python视频\day9\oldboy-1.avi")
# print(a)
#传输文件名称的时候要把md5完整校验传过去

import re, json,subprocess,os
# a = json.dumps({"han":123,"xu":456})
# x = "123"
# b = re.findall("^\{.*\}$",x)
# print(b)
# ret = subprocess.Popen("ls /home/han", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# file_size = os.stat("D:\资料\python\oldboy13\jobs\day7").st_size
# print(file_size)

# a = os.walk("D:\资料\python\oldboy13\jobs\day7")
# size = 0
# for root ,dirs ,files in a:
#     size+= sum([os.path.getsize(os.path.join(root,name)) for name in files])
# print(size,type(size))

# f = open("test.txt","w",encoding="utf8")
# while True:
#     user_input = input(">>: ")
#     if user_input == "exit":
#         break
#     f.write(user_input)
# print("write success")
# f.close()

file = "D:\资料\python\oldboy13\jobs\day9\myftp\module\\test.txt"
file = "D:\影音\音乐\\test\mqms2.mp3"
# with open(file,"wb") as file1:
#     file1.write(bytes("asdfghjklqwertyuiopzxcvbnm","utf8"))

# # file = "D:\影音\音乐\\test"
# r = open(file,"a+b")
# print(r.tell())
# r.write(bytes("\tasdfasdf","utf8"))
# print(r.tell(),type(r.tell()))
# r.close()
#
# with open(file, "rb") as filer, open("test1.txt", "wb") as filew:
#     filer.seek(5)
#     for i in filer:
#         filew.write(i)


# print(len(a))
# r.close()

# print(file_size,"8,754,350")
# def dir_size(path):
#     """
#     获取目录的大小
#     :param path:
#     :return:
#     """
#     a = os.walk(path)
#     size = 0
#     for root, dirs, files in a:
#         size += sum([os.path.getsize(os.path.join(root, name)) for name in files])
#     return size
# a = dir_size(file)
# print(a)

#8754350
#8754350

file = "..\\space\\han_1024"
# a = subprocess.call("mkdir %s"% file,shell=True)
# a = subprocess.call(["mkdir",r"..\space\test"],shell=False)
os.mkdir(file)